home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
vdl020d.zip
/
VRESFILE.DOC
< prev
next >
Wrap
Text File
|
1993-04-14
|
19KB
|
821 lines
{
════════════════════════════════════════════════════════════════════════════
Visionix Resource File (VRESFILE)
Copyright 1991,92,93 Visionix
ALL RIGHTS RESERVED
File text retrieving library. This unit provides the ability to use an
external text file for all text. This is so that programs being supplied
to non-English countries may modify the text to their native language.
Also, this provides a method of automating the creation of basic menus -
all data provided in the .MNU file.
────────────────────────────────────────────────────────────────────────────
Revision history in reverse chronological order:
Initials Date Comment
──────── ──────── ────────────────────────────────────────────────────────
lpg 03/15/93 Added Source Documentation
jrt 04/08/93 Cleaned up code to use VGEN functions;
(GetParamName, etc)
Added code to do indexing. Don't ask about
the indexing algorithym.
mep 02/11/93 Cleaned up code for beta release
jrt 11/21/92 Sync with beta 0.08
jrt 09/29/92 Converted function names to new format;
Added VRF_GetInt; cleaned up, etc. etc.
jrt 09/01/92 First logged revision.
════════════════════════════════════════════════════════════════════════════
}
(*-
ALL EXAMPLES ASSUME A RESOURCE FILE AS FOLLOWS...
File Name: PROGRAM.MNU
---FILE BEGIN---
MENU_BEGIN "Sector Menu"
"Read Sector "
"Write Sector "
"View/Edit Sector "
KEYS = "RWV"
ROWS = 5
COLS = 1
FORE = White
BACK = Cyan
MESG = "Select Action|<ESC>=Abort"
MENU_END
DIALOG_BEGIN "Out of Range"
"[Sorry but that Entry is out of Range.|Please Try Again.]"
TYPE = "[1]"
OPTS = "OK"
DIALOG_END
DIALOG_BEGIN "AbortRetry Dialog"
"[Error in Operation.||Please Select Action.]"
TYPE = "[1]"
OPTS = "[Abort|Retry|Ignore|Fail]"
KEYS = "ARIF"
DIALOG_END
TEXT "Program Name" = "Sector Edit Program, Ver 1.0"
TEXT "DevName" = "Device Name :"
TEXT "TotBlks" = "Total Sectors :"
TEXT "BPS" = "Bytes Per Sector :"
TEXT "SPC" = "Sectors Per Cluster :"
TEXT "CPD" = "Clusters Per Drive :"
TEXT "EnterBlk" = "Enter Sector to Load"
TEXT "PressKey" = "Press any key to Continue"
TEXT "Reading" = "Reading Sector. One Moment..."
TEXT "Writing" = "Writing Sector. One Moment..."
TEXT "View/Edit" = "Use Arrow Keys to Scroll|<ESC> to Quit"
TEXT "NoMessage" = " "
TEXT "CurrInfo" = "Drive : %D Current Sector : %S"
TEXT "GB" = "Thousand Bytes"
TEXT "KB" = "KiloByte"
TEXT "MB" = "MegaByte"
TEXT "Block" = "Sector"
INTEGER "One" = 1
INTEGER "Ten" = 10
INTEGER "Hundred" = 100
INTEGER "Thousand" = 1000
INTEGER "Byte" = 256
INTEGER "SectSize" = 256
INTEGER "BlkSize" = 512
INTEGER "ClustSize" = 2048
INTEGER "DrvSize" = 20
INTEGER "Kilo" = 1024
INTEGER "Meg" = 1048576
COLOR "Black" = 0
COLOR "Blue" = 1
COLOR "Green" = 2
COLOR "Cyan" = 3
COLOR "Red" = 4
COLOR "Magenta" = 5
COLOR "Brown" = 6
COLOR "Lt Gray" = 7
COLOR "Dk Gray" = 8
COLOR "Lt Blue" = 9
COLOR "Lt Green" = 10
COLOR "Lt Cyan" = 11
COLOR "Lt Red" = 12
COLOR "Lt Magenta" = 13
COLOR "Yellow" = 14
COLOR "White" = 15
---FILE END---
-*)
Unit VResFile;
Uses
VTypes,
VGen,
VDOSHigh,
VWinlow;
{────────────────────────────────────────────────────────────────────────────}
Procedure VRF_New( FName : ST80 );
Procedure VRF_GetMenu( ID : ST80;
Var Menu : TMenu;
Var Keys : ST80;
Var NumChoices : INTEGER;
Var Rows : INTEGER;
Var Cols : INTEGER;
Var FC : INTEGER;
Var BC : INTEGER;
Var Message : ST80 );
Function VRF_DoMenu( Opts : ST80;
ID : ST80;
X : INTEGER;
Y : INTEGER;
FC : INTEGER;
BC : INTEGER ) : INTEGER;
Function VRF_DoMenu_Kill( Opts : ST80;
ID : ST80;
X : INTEGER;
Y : INTEGER;
FC : INTEGER;
BC : INTEGER ) : INTEGER;
Function VRF_GetDialog( ID : ST80 ) : STRING;
Function VRF_GetText( ID : ST80 ) : STRING;
Function VRF_GetInt( ID : ST80 ) : LONGINT;
Function VRF_GetColorNum( ID : ST80 ) : BYTE;
Procedure VRF_Dispose;
{────────────────────────────────────────────────────────────────────────────}
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure FTError( S : ST80 );
[PARAMETERS]
S Resource File Error Message
[RETURNS]
(None)
[DESCRIPTION]
Takes the Provided Resource File Error Message and Displays it in the top
left of the Screen. Then Shuts down the Program.
[SEE-ALSO]
[EXAMPLE]
BEGIN
WriteLn( 'About to Call FTError...' );
FTError( 'Could not find Menu Item' ); { HALTS HERE }
WriteLn( 'Should have never gotten here!' );
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function GetStartLine( ID : ST80 ) : INTEGER;
[PARAMETERS]
ID Resource File Item ID Name to search for
[RETURNS]
The Indexed Line Number which this Item ID Name represents.
[DESCRIPTION]
Takes the Item ID Name and searches the Pre-Loaded Resource File Data
until it either finds this item or fails to. If it is found then the
Line Index Number is returned.
If not, then this is an Error Condition though nothing happens.
[SEE-ALSO]
[EXAMPLE]
{NOTE: All Examples use Above Demo Resource File}
BEGIN
WriteLn( 'Found at Line ',GetStartLine( 'Blue' ) );
{ Should have Found this ID on Line x of the example Resource File }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure VRF_New( FName : ST80 );
[PARAMETERS]
FName Resource File to Load
[RETURNS]
(None)
[DESCRIPTION]
Reads the Resource File Data from the given File Name and Loads all
the Data in RAM for Quick Access.
[SEE-ALSO]
[EXAMPLE]
{NOTE: All Examples use Above Demo Resource File}
Uses VGen,VWinHigh,VResFile;
VAR
I : INTEGER;
BEGIN
WOpen( '▒',BLACK,BLUE,'CLOCK' );
VRF_New( 'PROGRAM.MNU' );
I := WGemDialogBox( VRF_GetDialog( 'AbortRetry' ) );
WMessage( 'Selection : ' + IntToStr(i) + '|' + VRF_GetText('PressKey'),
WHITE,CYAN );
While NOT WKeyPressed Do;
WDispose;
WClose;
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure VRF_GetMenu( ID : ST80;
Var Menu : TMenu;
Var Keys : ST80;
Var NumChoices : INTEGER;
Var Rows : INTEGER;
Var Cols : INTEGER;
Var FC : INTEGER;
Var BC : INTEGER;
Var Message : ST80 );
[PARAMETERS]
ID Resource File Menu ID Name
Menu VAR Returned Menu Data
Keys VAR Returned Active Menu Keys
NumChoices VAR Returned Number of Menu Choices
Rows VAR Returned Number of Menu Rows
Cols VAR Returned Number of Menu Cols
FC VAR Returned Menu Foreground Color
BC VAR Returned Menu Background Color
Message VAR Returned Message Line associated with Menu
[RETURNS]
Function : None
(VAR : [Menu] Menu Data)
(VAR : [Keys] Active Menu Keys)
(VAR : [NumChoices] Number of Menu Choices)
(VAR : [Rows] Number of Menu Rows)
(VAR : [Cols] Number of Menu Cols)
(VAR : [FC] Menu Foreground Color)
(VAR : [BC] Menu Background Color)
(VAR : [Message] WMessage Line associated with Menu)
[DESCRIPTION]
Searches the Pre-Loaded Resource File Data for the Menu identified by the
ID Name. When this is found, loads and returns all the Menu Information
associated with this.
[SEE-ALSO]
VFR_GetDialog
VFR_GetText
VFR_GetInt
VRF_GetColorNumber
VRF_DoMenu
VRF_DoMenu_Kill
[EXAMPLE]
{NOTE: All Examples use Above Demo Resource File}
Uses VGen,VWinHigh,VResFile;
VAR
Menu : TMenu;
Keys, Msg : ST80;
Num,
Rows,Cols,
FC,BC,
I,Start : INTEGER;
BEGIN
WOpen( '▒', BLACK,BLUE, 'CLOCK' );
VRF_New( 'Program.mnu' );
VRF_Menu( 'Sector Menu', Menu, Keys, Num, Rows, Cols, FC,BC, Msg );
WMessage( Msg, WHITE,CYAN );
Start := 1;
I := WAutoMenu_Kill( Addr( Menu ),
Num,
Cols,
Rows,
Keys,
X, Y,
FC, BC,
FC, BC,
'Sector Menu',
Start );
WMessage( 'Selection : '+IntToStr( i )+'|Press any Key to Quit',
WHITE,CYAN );
While NOT WKeyPressed Do;
VRF_Dispose;
WClose;
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function VRF_GetDialog( ID : ST80 ) : STRING;
[PARAMETERS]
ID Resource File Dialog ID Name
[RETURNS]
Dialog Box String associated with ID Name
[DESCRIPTION]
Searches the Pre-Loaded Resource File Data for the Dialog identified by
the ID Name. When this is found, loads and returns the Dialog String
information associated with this.
[SEE-ALSO]
VFR_GetMenu
VFR_GetText
VFR_GetInt
VRF_GetColorNumber
[EXAMPLE]
{NOTE: All Examples use Above Demo Resource File}
Uses VGen,VWinHigh,VResFile;
VAR
S : STRING;
I : INTEGER;
BEGIN
WOpen( '▒',BLACK,BLUE,'CLOCK' );
VRF_New( 'PROGRAM.MNU' );
I := WGemDialogBox( VFR_GetDialog( 'AbortRetry' ) );
WMessage( 'Selection : ',IntToStr(i)+'|Press any key to Quit',
WHITE,CYAN );
While NOT WKeyPressed Do;
WDispose;
WClose;
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function VRF_GetText( ID : ST80 ) : STRING;
[PARAMETERS]
ID File-Text Text ID Name
[RETURNS]
Text Associated with the Text ID Name
[DESCRIPTION]
Searches the Pre-Loaded File-Text Data for the Text identified by the
ID Name. When this is found, loads and returns the Text String
information associated with this.
[SEE-ALSO]
VFR_GetMenu
VFR_GetDialog
VFR_GetInt
VRF_GetColorNumber
[EXAMPLE]
{NOTE: All Examples use Above Demo Resource File}
Uses VWinHigh,VResFile;
VAR
BPS,
SPC,
CPD : LONGINT;
BEGIN
WOpen( '▒', BLACK,BLUE, 'CLOCK' );
VRF_New( 'PROGRAM.MNU' );
WPrgName( VRF_Text( 'ProgName' ) );
WNew( 10, 5, 40, 15, WHITE,CYAN,WHITE,CYAN, 'Drive Info' )
BPS := VRF_GetInt('BlkSize') DIV VRF_GetInt('SectSize')
SPC := VRF_GetInt('ClustSize') DIV BPS;
CPD := VRF_GetInt('DrvSize') * VRF_GetInt('MB') DIV SPC;
WriteLn ( VRF_Text( 'BPS' ), BPS );
WriteLn ( VRF_Text( 'SPC' ), SPC );
WriteLn ( VRF_Text( 'CPD' ), CPD );
WMessage( VRF_GetText( 'PressKey' ), WHITE,CYAN );
While NOT WKeyPressed Do;
WDispose( 'Drive Info' );
VRF_Dispose;
WClose;
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function VRF_GetInt( ID : ST80 ) : LONGINT;
[PARAMETERS]
ID Resource File Integer ID Name
[RETURNS]
Integer Value associate with the Integer ID Name
[DESCRIPTION]
Searches the Pre-Loaded Resource File Data for the Integer Value identified
by the ID Name. When this is found, loads and returns the Integer Value
information associated with this.
[SEE-ALSO]
VFR_GetMenu
VFR_GetDialog
VFR_GetText
VFR_GetColorNumber
[EXAMPLE]
{NOTE: All Examples use Above Demo Resource File}
Uses VWinHigh,VResFile;
VAR
BPS,
SPC,
CPD : LONGINT;
BEGIN
WOpen( '▒', BLACK,BLUE, 'CLOCK' );
VRF_New( 'PROGRAM.MNU' );
WPrgName( VRF_Text( 'ProgName' ) );
WNew( 10, 5, 40, 15, WHITE,CYAN,WHITE,CYAN, 'Drive Info' )
BPS := VRF_GetInt('BlkSize') DIV VRF_GetInt('SectSize')
SPC := VRF_GetInt('ClustSize') DIV BPS;
CPD := VRF_GetInt('DrvSize') * VRF_GetInt('MB') DIV SPC;
WriteLn ( VRF_Text( 'BPS' ), BPS );
WriteLn ( VRF_Text( 'SPC' ), SPC );
WriteLn ( VRF_Text( 'CPD' ), CPD );
WriteLn;
WriteLn( 'KiloByte = ', VRF_GetInt( 'KB' ) );
WriteLn( 'GigaByte = ', VRF_GetInt( 'GB' ) );
WMessage( VRF_GetText( 'PressKey' ), WHITE,CYAN );
While NOT WKeyPressed Do;
WDispose( 'Drive Info' );
VRF_Dispose;
WClose;
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function VRF_GetColorNum( ID : ST80 ) : BYTE;
[PARAMETERS]
ID Resource File Color ID Name
[RETURNS]
Color Value associate with the Color ID Name
[DESCRIPTION]
Searches the Pre-Loaded Resource File Data for the Color Value identified
by the ID Name. When this is found, loads and returns the Color Value
information associated with this.
[SEE-ALSO]
VFR_GetMenu
VFR_GetDialog
VFR_GetText
VFR_GetInt
[EXAMPLE]
{NOTE: All Examples use Above Demo Resource File}
BEGIN
VRF_New( 'Program.mnu' );
WriteLn( 'Red = ', VRF_GetColorNum( 'Red' ) );
WriteLn( 'Blue = ', VRF_GetColorNum( 'Green' ) );
WriteLn( 'Green = ', VRF_GetColorNum( 'Blue' ) );
WriteLn( VRF_GetText( 'PressKey' ) );
While NOT WKeyPressed Do;
VRF_Dispose;
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function VRF_DoMenu( Opts : ST80;
ID : ST80;
X : INTEGER;
Y : INTEGER;
FC : INTEGER;
BC : INTEGER ) : INTEGER;
[PARAMETERS]
Opts Menu Options
ID Resource File Menu ID Name (Also used as Window Name)
X Menu X Coordinate
Y Menu Y Coordinate
FC Overriding Foreground Color (-1 = Use data from File)
BC Overriding Background Color (-1 = Use data from File)
[RETURNS]
User Menu Item Selection
[DESCRIPTION]
Searches the Pre-Loaded Resource File Data for the Menu identified by
the ID Name. When this is found, loads and executes the Menu,
returning the User Menu Selection.
This Function does not Remove the Created Menu Window from the Screen,
which must be removed by the programmer manually. The Window Name is
the same as the Resource File Menu ID Name. So be sure that those
Names are what you would want displayed at the top of a Menu Window.
[SEE-ALSO]
VRF_GetMenu
VRF_DoMenu_Kill
[EXAMPLE]
{NOTE: All Examples use Above Demo Resource File}
Uses VGen,VWinHigh,VResFile;
VAR
I : INTEGER;
BEGIN
WOpen( '▒',BLACK,BLUE,'SHADOW' );
VRF_New( 'PROGRAM.MNU' );
I := VRF_DoMenu( '', 'Menu Name', 20, 5, -1, -1 );
WMessage( 'Selection : '+IntToStr(i)+'|'+VRF_GetText('PressKey'),
WHITE, CYAN );
While NOT WKeyPressed Do;
WDispose( 'Menu Name' );
VRF_Dispose;
WClose;
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function VRF_DoMenu_Kill( Opts : ST80;
ID : ST80;
X : INTEGER;
Y : INTEGER;
FC : INTEGER;
BC : INTEGER ) : INTEGER;
[PARAMETERS]
Opts Menu Options
ID Resource File Menu ID Name (Also used as Window Name)
X Menu X Coordinate
Y Menu Y Coordinate
FC Overriding Foreground Color (-1 = Use data from File)
BC Overriding Background Color (-1 = Use data from File)
[RETURNS]
User Menu Item Selection
[DESCRIPTION]
Searches the Pre-Loaded Resource File Data for the Menu identified by
the ID Name. When this is found, loads and executes the Menu,
returning the User Menu Selection. Also removes the Created Menu
Window from the Screen before returning.
[SEE-ALSO]
VRF_GetMenu
VRF_DoMenu
[EXAMPLE]
{NOTE: All Examples use Above Demo Resource File}
Uses VGen,VWinHigh,VResFile;
VAR
I : INTEGER;
BEGIN
WOpen( '▒',BLACK,BLUE,'SHADOW' );
VRF_New( 'PROGRAM.MNU' );
I := VRF_DoMenu_Kill( '', 'Menu Name', 20, 5, -1, -1 );
WMessage( 'Selection : '+IntToStr(i)+'|'+VRF_GetText('PressKey'),
WHITE, CYAN );
While NOT WKeyPressed Do;
VRF_Dispose;
WClose;
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure VRF_Dispose;
[PARAMETERS]
(None)
[RETURNS]
(None)
[DESCRIPTION]
Deallocates all data Previously Loaded by the
[SEE-ALSO]
VRF_New
[EXAMPLE]
{NOTE: All Examples use Above Demo Resource File}
Uses VGen,VWinHigh,VResFile;
VAR
S : STRING;
I : INTEGER;
BEGIN
WOpen( '▒',BLACK,BLUE,'CLOCK' );
VRF_New( 'PROGRAM.MNU' );
S := VFR_GetDialog( 'AbortRetry' );
I := WGemDialogBox( S );
WMessage( 'Selection : ',IntToStr(i)+'|Press any key to Quit',
WHITE,CYAN );
While NOT WKeyPressed Do;
WDispose;
WClose;
END;